module.exports = Behavior({
    lifetimes: {
        created: function() {
            this.nextCallback = null;
        },
        detached: function() {
            this.cancelNextCallback();
        }
    },
    methods: {
        safeSetData: function(t, a) {
            var l = this;
            this.pendingData = Object.assign({}, this.data, t), a = this.setNextCallback(a), 
            this.setData(t, function() {
                l.pendingData = null, a();
            });
        },
        setNextCallback: function(t) {
            var a = this, l = !0;
            return this.nextCallback = function(n) {
                l && (l = !1, a.nextCallback = null, t.call(a, n));
            }, this.nextCallback.cancel = function() {
                l = !1;
            }, this.nextCallback;
        },
        cancelNextCallback: function() {
            null !== this.nextCallback && (this.nextCallback.cancel(), this.nextCallback = null);
        }
    }
});